package hospital;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author oldliu
 * @since 1.0
 */
public class SerTest {
    public static void main(String[] args) {
        try {
            ServerSocket st=new ServerSocket(8888);
            System.out.println("监听在8888端口");
            while (true){
                Socket s = st.accept();//建立连接
                System.out.println("s:"+s.getInetAddress()+",端口："+s.getPort()+",本地端口："+s.getLocalPort());
                InputStream in = s.getInputStream();
                OutputStream out = s.getOutputStream();
                int ch=0;
                while ((ch=in.read())!=-1){
                    System.out.print((char)ch);
                }
                s.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
